import 'package:built_collection/built_collection.dart';
import 'package:equatable/equatable.dart';
import 'package:backend.core/core/domain/entities/web/web_purchased_subscription_info.dart';

class YookassaPurchasedSubscriptionInfo extends Equatable implements WebPurchasedSubscriptionInfo {
  const YookassaPurchasedSubscriptionInfo({
    required this.originalTransactionId,
    required this.userId,
    required this.purchaseItemSku,
    required this.autoRenewalEnabled,
    required this.currentRenewalAttemptTimes,
    required this.test,
  });

  @override
  final String originalTransactionId;

  @override
  final String userId;

  @override
  final String purchaseItemSku;

  @override
  final bool autoRenewalEnabled;

  @override
  final BuiltList<DateTime> currentRenewalAttemptTimes;

  @override
  final bool test;

  @override
  List<Object?> get props {
    return [
      originalTransactionId,
      userId,
      purchaseItemSku,
      autoRenewalEnabled,
      currentRenewalAttemptTimes,
      test,
    ];
  }

  @override
  YookassaPurchasedSubscriptionInfo copyWith({
    String Function()? originalTransactionId,
    String Function()? userId,
    String Function()? purchaseItemSku,
    bool Function()? autoRenewalEnabled,
    BuiltList<DateTime> Function()? currentRenewalAttemptTimes,
    bool Function()? test,
  }) {
    return YookassaPurchasedSubscriptionInfo(
      originalTransactionId:
          originalTransactionId == null ? this.originalTransactionId : originalTransactionId(),
      userId: userId == null ? this.userId : userId(),
      purchaseItemSku: purchaseItemSku == null ? this.purchaseItemSku : purchaseItemSku(),
      autoRenewalEnabled:
          autoRenewalEnabled == null ? this.autoRenewalEnabled : autoRenewalEnabled(),
      currentRenewalAttemptTimes: currentRenewalAttemptTimes == null
          ? this.currentRenewalAttemptTimes
          : currentRenewalAttemptTimes(),
      test: test == null ? this.test : test(),
    );
  }
}
